/**
 * 基础表单
 */
Ext.define('Jason.view.example.form.basic.MainView',{
	extend : 'Wys.basic.BaseForm',
	//layout: 'anchor',
	requires : [
		'Wys.picker.BeginEndDate',
		'Wys.form.field.Time',
		'Wys.form.field.MonthField'
	],
	flex:1,
	autoHeight:true,
    defaults: {
        anchor: '100%',
		margin : 8
    },
    defaultType: 'textfield',
    items: [{
		xtype : 'wys-displayfield',
		fieldLabel : 'wys-displayfield',
		//fieldPostfix : '<i class="fa fa-user"></i>',
		fieldPrefix : '',
		value : '这是显示的数据'
	},{
		xtype : 'monthField',
		fieldLabel : '请选择年月'
	},{
        fieldLabel: '必输文本框',
		afterLabelTextTpl:cfg.reqired,
        allowBlank: false
    },{
        xtype: 'textfield',
        name: 'textfield1',
        fieldLabel: '文本框'
    },{
        xtype: 'textfield',
        name: 'password1',
        inputType: 'password',
        fieldLabel: '密码框'
    },{
        xtype: 'textareafield',
        name: 'textarea1',
        fieldLabel: '多行文本框'
    },{
		xtype : 'htmlEditor',
		fieldLabel : '富文本编辑器'
	}, {
        xtype: 'displayfield',
        name: 'displayfield1',
        fieldLabel: '显示文本',
        value: '显示文本 <span style="color:green;">value</span>'
    }, {
        xtype: 'numberfield',
        name: 'numberfield1',
        fieldLabel: '数字输入框',
        minValue: 0,
        maxValue: 50
    }, {
        xtype: 'checkboxfield',
        name: 'checkbox1',
        fieldLabel: '复选框',
        boxLabel: '显示'
    }, {
        xtype: 'radiofield',
        name: 'radio1',
        value: 'radiovalue1',
		fieldLabel: '单选框',
        boxLabel: '显示1'
    }, {
        xtype: 'radiofield',
        name: 'radio1',
        value: '显示2',
        fieldLabel: '',
        labelSeparator: '',
        hideEmptyLabel: false,
        boxLabel: 'radio 2'
    }, {
        xtype: 'datefield',
        name: 'date1',
        fieldLabel: '日期选择框'
    }/*, {
        xtype: 'timefield',
        name: 'time1',
        fieldLabel: '时间选择框',
        minValue: '1:30 AM',
        maxValue: '9:15 PM'
    }*/],
	buttonAlign : 'center',
    buttons: [{
        text: '重置',
        handler: function() {
            this.up('form').getForm().reset();
        }
    }, {
        text: '保存',
        formBind: true, //only enabled once the form is valid
        disabled: true,
        handler: function() {
            var form = this.up('form').getForm();
            if (form.isValid()) {
                form.submit({
                    success: function(form, action) {
                       Ext.Msg.alert('Success', action.result.msg);
                    },
                    failure: function(form, action) {
                        Ext.Msg.alert('Failed', action.result.msg);
                    }
                });
            }
        }
    }]
});